#pragma once

#include"RBTree.h"

namespace myset
{
	template<class K>
	class set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename RBTree<K, const K, SetKeyOfT>::Iterator iterator;
		typedef typename RBTree<K, const K, SetKeyOfT>::Const_Iterator const_iterator;

		iterator begin()
		{
			return _t.Begin();
		}

		iterator end()
		{
			return _t.End();
		}

		const_iterator begin() const
		{
			return _t.Begin();
		}

		const_iterator end() const
		{
			return _t.End();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return _t.Insert(key);
		}

		iterator find(const K& key)
		{
			return _t.Find(key);
		}
	private:
		RBTree<K, const K, SetKeyOfT> _t;
	};

	void Print(const set<int>& s)
	{
		for (const auto& e : s)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	void test_set()
	{
		myset::set<int> s;
		s.insert(2);
		s.insert(4);
		s.insert(6);
		s.insert(21);
		s.insert(56);
		s.insert(56);
		s.insert(8);

		Print(s);
		//myset::set<int>::iterator it = s.begin();
		//while (it != s.end())
		//{
		//	cout << *it << " ";
		//	++it;
		//}
		//cout << endl;
	}
}
